<?php 
$this->headTitle(" - Index");
?>
<h1>List All Books</h1>
<a href="<?php echo $this->url(array('controller'=>'index', 'action'=>'add'))?>">Add new book</a>
<?php
echo $this->paginationControl($this->books,'Sliding','./index/pageBook.phtml');
?>
<table class="main" align="center" border="1">
<tr>
<th>Image</th>
<th>Detail</th>
</tr>

<?php

foreach($this->books as $book){
	//print_r($book);
	echo '<tr>
	<td valign="top" align="center" width="200px"><img src="'.$this->baseUrl().'/public/upload/'.$book->image.'" height="200px"/></td>
	<td valign="top"><a href="'.$this->url(array("controller"=>"index", "action" => "edit", "id" => $book->id)).'">'.$book->title.' ('.$book->id.') </a><br />
	<b>Authors:</b> '.$book->author.' <br />
	<b>Price:</b> '.$book->price.' <br />
	<b>Post by:</b> '.$book->posted_by.' <br />
	<b>Post date:</b> '.date('d-m-Y H:m:s', strtotime($book->posted_date)).' <br />
	<b>Description:</b> '.$book->description.' <br />
	<a href="'.$this->url(array('controller'=>'index', 'action'=>'delete', 'id'=>$book->id)).'">Delete Book</a>
	</td>
	</tr>';
	
}
?>
</table>

<?php
echo $this->paginationControl($this->books,'Sliding','./index/pageBook.phtml');
echo $this->message;
?>